package com.android.launcher3.setting;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.android.launcher3.BaseActivity;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;

public class LauncherHelpActivity extends BaseActivity {

    private static final String TAG = "LauncherHelpActivity";


    private final static double SCALE = 2;

    private LinearLayout layoutContainer;
    private View icBackToHome;
    private ImageView ivQRcode;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        setContentView(R.layout.launcher_help_activity);
        setUpView();
    }

    private void setUpView() {
        layoutContainer = findViewById(R.id.layout_container);
        icBackToHome = findViewById(R.id.ic_back_to_home);
        ivQRcode = findViewById(R.id.iv_qrcode);
        findViewById(R.id.ic_back_to_home).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                Intent home = new Intent(Intent.ACTION_MAIN);
//                home.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//                home.addCategory(Intent.CATEGORY_HOME);
//                LauncherHelpActivity.this.startActivity(home);
                finish();
            }
        });
        screenAdaptation();
    }

    private void screenAdaptation() {


        layoutContainer.post(() -> {
            DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
            if (Utilities.isLongStripScreen(getApplicationContext())) {

                LinearLayout.LayoutParams icBackToHomeLayoutParams = (LinearLayout.LayoutParams) icBackToHome.getLayoutParams();
                icBackToHomeLayoutParams.width = Utilities.pxFromDp(97.5f, displayMetrics);
                icBackToHomeLayoutParams.height = Utilities.pxFromDp(60, displayMetrics);
                icBackToHome.setLayoutParams(icBackToHomeLayoutParams);

                LinearLayout.LayoutParams icQRCodeLayoutParams = (LinearLayout.LayoutParams) ivQRcode.getLayoutParams();
                icQRCodeLayoutParams.width = Utilities.pxFromDp(70, displayMetrics);
                icQRCodeLayoutParams.height = Utilities.pxFromDp(70, displayMetrics);
                ivQRcode.setLayoutParams(icQRCodeLayoutParams);
            }
        });


    }
}
